// 验证码倒计时

export default function (resetTime = 60) {
  const time = ref(resetTime)
  const isSend = ref(false)
  let timer = null

  const send = () => {
    isSend.value = true
    timer = setInterval(() => {
      time.value--

      if (time.value <= 0) {
        clearInterval(timer)
        time.value = resetTime
        isSend.value = false
      }
    }, 1000)
  }

  return { time, isSend, send }
}
